import React, { Component } from "react";
import PropTypes from "prop-types"; //类型限制
import Item from "../Item";
import "./index.css";
export default class List extends Component {

  // 对接收的props进行：类型必要性的限制
  static propTypes = {
    updateTodo: PropTypes.func.isRequired,
    todos: PropTypes.array.isRequired,
    headleDelete: PropTypes.func.isRequired
  }
  render() {
    const { todos, updateTodo, headleDelete } = this.props;
    console.log(this.props);
    return (
      <div>
        <ul className="todo-main">
          {todos.map((item) => {
            return <Item key={item.id} {...item} updateTodo={updateTodo} headleDelete={headleDelete} />;
          })}
        </ul>
      </div>
    );
  }
}
